<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Models\CommunityGoods;
use App\Models\CommunityHead;
use App\Models\CommunityShop;
use App\Service\CommonService;
use Illuminate\Http\Request;
/*
*门店端控制器
 * 何家令11.24

 */
class ShopController extends Controller
{
    //查看这个用户是否是团长(如果是直接查询出 团长信息,门店信息,商品信息)
    public function selectHead(Request $request)
    {
        $userid=intval($request->get('user_id'));
        if(empty($userid)) return CommonService::fail(9999,'用户id不能为空',null);
        //团长信息
         $headData=CommunityHead::where('user_id',$userid)->get()->toArray();
         if($headData)
         {
             //门店信息
          $shopData=CommunityShop::where('community_id',$headData[0]['community_id'])->get()->toArray();
          print_r($shopData);die();
          //门店商品信息
          $goodsData=CommunityGoods::where('community_shop_id',$shopData[0]['id'])->get()->toArray();
         return CommonService::success(200,'查询成功',['headData'=>$headData,'shopData'=>$shopData,'goodsData'=>$goodsData]);
         }
    }
    //查看所属门店的商品
    public function shopGoods(Request $request)
    {
        $user_id=intval($request->get('user_id'));


    }
}
